package icse;

import atae.AtaeSvNacar;

public class Rutinas {

	public static String getPath(//AtaeSvRutinaUtilsIF rutinaUtils, 
			String SPATH, String SFILE){
	    String ENTORNO = System.getProperty("ENTORNO");
	    String DIRCONFIG = "";
	    String PATH = "";
	    String FILE = "";
	    if (ENTORNO == null) {
	      PATH = (SPATH.substring(0, 1).equalsIgnoreCase("/")) ? 
	    		  SPATH.substring(1, SPATH.length()) : SPATH;
	      PATH = "D:/nacar/RAD/nacar/WebContent/" + PATH;
	      FILE = (SFILE.substring(0, 1).equalsIgnoreCase("/")) ? 
	    		  SFILE.substring(1, SFILE.length()) : SFILE;
	      DIRCONFIG = DIRCONFIG + (
			        (PATH.substring(PATH.length() - 1, PATH.length())
			        .equalsIgnoreCase("/")) ? PATH + FILE : new StringBuffer(String.valueOf(PATH)).append("/")
			        .append(FILE).toString());
	    }
	    else {
	      PATH = (SPATH.substring(0, 1).equalsIgnoreCase("/")) ? 
	    		  SPATH.substring(1, SPATH.length()) : SPATH;
	      FILE = (SFILE.substring(0, 1).equalsIgnoreCase("/")) ? 
	    		  SFILE.substring(1, SFILE.length()) : SFILE;
	      PATH = PATH + (
		        (PATH.substring(PATH.length() - 1, PATH.length())
		        .equalsIgnoreCase("/")) ? FILE : new StringBuffer("/").append(FILE).toString());
	      DIRCONFIG = AtaeSvNacar.getDirectorioConfiguracion();

	      DIRCONFIG = DIRCONFIG.substring(1, DIRCONFIG.length());
	      DIRCONFIG = "/" + DIRCONFIG.substring(0, DIRCONFIG.indexOf("/"));
	      DIRCONFIG = DIRCONFIG + (
			        (DIRCONFIG.substring(DIRCONFIG.length() - 1, 
			        DIRCONFIG.length()).equalsIgnoreCase("/")) ? PATH : 
			        new StringBuffer("/").append(PATH).toString());
	    }
	    System.out.println("PATH: " + DIRCONFIG);
	    return DIRCONFIG;
	  }	
	
}
